<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="button" value="click me" onclick="hello()" id="btn">
    <script>
        //在DOM元素中直接绑定
        // function hello(){
        //     alert("hello world!");
        // }

        //在javascript中直接绑定
        // document.getElementById("btn").onclick=function(){
        //     alert("hello world!");
        // }

        //绑定事件监听
        //语法：element.addEventListener(event,function,useCaptur)  IE标准attachEvent
        //优点：可以绑定多个事件
        document.getElementById("btn"),addEventListener("click",function hello(){
            alert("hello world!");
        })

    </script>
</body>
</html>